package com.linko.intelligent.common.util;


import com.linko.intelligent.base.UserInfo;

public class UserContext {
    private static ThreadLocal<UserInfo> loginEntityThreadLocal = new ThreadLocal<>();


    public static UserInfo getUserSession() {
        return loginEntityThreadLocal.get();
    }

    public static void setUserSession(UserInfo entity) {
        loginEntityThreadLocal.set(entity);
    }

    public static void removeUserSession() {
        loginEntityThreadLocal.remove();
    }

    public static Long getUserId() {
        if (getUserSession() == null) {
            return null;
        }
        return getUserSession().getId();
    }

}
